package gui.components.map.objects;

import gui.components.map.engine.RenderQueue;
import gui.components.map.engine.RenderQueueType;

import java.awt.geom.Line2D;
import javax.swing.JPanel;


public class objRasterGrid extends objGrid{

	private double _gridboxheight;
	private double _gridboxwidth;
	private RenderQueue __renderqueue_gridx;
	private RenderQueue __renderqueue_gridy;
	
	public objRasterGrid()
	{
		super();
	}
		
	public void GenerateGrid(JPanel _panel)
	{		
		__renderqueue_gridx = new RenderQueue();
		__renderqueue_gridy = new RenderQueue();
		
		__renderqueue_gridx.SetType(RenderQueueType.GRIDRASTER);
		__renderqueue_gridy.SetType(RenderQueueType.GRIDRASTER);

		_renderqueue.Add(__renderqueue_gridx);
		_renderqueue.Add(__renderqueue_gridy);
		
		
		GenerateX(_panel);
		GenerateY(_panel);
	}
	
	private void GenerateX(JPanel _panel)
	{
		int _limiter = _panel.getHeight();
		int _mirror_mod = _panel.getWidth();
		int _point = 0 - (int)_gridboxheight;
		
		do 
		{
			_point += _gridboxwidth;
			
			Line2D.Double _line = new Line2D.Double(0, _point,_mirror_mod,_point);
			__renderqueue_gridx.Add(new cShape(_line, GetColor()));
			
		} while(_point < _limiter);
	}
	
	private void GenerateY(JPanel _panel)
	{
		int _limiter = _panel.getWidth();
		int _mirror_mod = _panel.getHeight();
		int _point = 0 - (int)_gridboxwidth;
		
		do 
		{
			_point += _gridboxwidth;
			
			Line2D.Double _line = new Line2D.Double(_point, 0,_point,_mirror_mod);
			__renderqueue_gridy.Add(new cShape(_line, GetColor()));
			
		} while(_point < _limiter);
	}

	public double GetGridboxheight() {
		return _gridboxheight;
	}
	
	public void SetGridboxheight(double _gridboxheight) {
		this._gridboxheight = _gridboxheight;
	}
	
	public double GetGridboxwidth() {
		return _gridboxwidth;
	}
	
	public void SetGridboxwidth(double _gridboxwidth) {
		this._gridboxwidth = _gridboxwidth;
	}
}
